package com.ruoyi.web.controller.mobile;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.mobile.domain.HuaweiHealthDetail;
import com.ruoyi.mobile.service.IHuaweiHealthDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 华为健康详情数据Controller
 * 
 * @author ruoyi
 * @date 2022-09-23
 */
@RestController
@RequestMapping("/mobile/detail")
public class HuaweiHealthDetailController extends BaseController
{
    @Autowired
    private IHuaweiHealthDetailService huaweiHealthDetailService;

    /**
     * 查询华为健康详情数据列表
     */
    @PreAuthorize("@ss.hasPermi('mobile:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(HuaweiHealthDetail huaweiHealthDetail)
    {
        startPage();
        List<HuaweiHealthDetail> list = huaweiHealthDetailService.selectHuaweiHealthDetailList(huaweiHealthDetail);
        return getDataTable(list);
    }

    /**
     * 导出华为健康详情数据列表
     */
    @PreAuthorize("@ss.hasPermi('mobile:detail:export')")
    @Log(title = "华为健康详情数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HuaweiHealthDetail huaweiHealthDetail)
    {
        List<HuaweiHealthDetail> list = huaweiHealthDetailService.selectHuaweiHealthDetailList(huaweiHealthDetail);
        ExcelUtil<HuaweiHealthDetail> util = new ExcelUtil<HuaweiHealthDetail>(HuaweiHealthDetail.class);
        util.exportExcel(response, list, "华为健康详情数据数据");
    }

    /**
     * 获取华为健康详情数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('mobile:detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(huaweiHealthDetailService.selectHuaweiHealthDetailById(id));
    }

    /**
     * 新增华为健康详情数据
     */
    @PreAuthorize("@ss.hasPermi('mobile:detail:add')")
    @Log(title = "华为健康详情数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HuaweiHealthDetail huaweiHealthDetail)
    {
        return toAjax(huaweiHealthDetailService.insertHuaweiHealthDetail(huaweiHealthDetail));
    }

    /**
     * 修改华为健康详情数据
     */
    @PreAuthorize("@ss.hasPermi('mobile:detail:edit')")
    @Log(title = "华为健康详情数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HuaweiHealthDetail huaweiHealthDetail)
    {
        return toAjax(huaweiHealthDetailService.updateHuaweiHealthDetail(huaweiHealthDetail));
    }

    /**
     * 删除华为健康详情数据
     */
    @PreAuthorize("@ss.hasPermi('mobile:detail:remove')")
    @Log(title = "华为健康详情数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(huaweiHealthDetailService.deleteHuaweiHealthDetailByIds(ids));
    }
}
